﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebProjectOrder.WebServices;

namespace WebProjectOrder.BusinessLayer
{
    public class StoreRoomManager
    {

        #region Atributos
        private bool _IsError;
        private String _ErrorMessage;
        private bool _DefiniteError;
        private static StoreRoomManager _instance;
        private List<StoreRoom> _stores;
//        private List<> BodegaArticulo
        #endregion

        #region Propiedades
        public bool IsError
        {
            get
            {
                bool temp = _IsError;
                _IsError = false;
                return temp;
            }
        }

        public String ErrorMessage
        {
            get
            {
                String temp = _ErrorMessage;
                _IsError = false;
                _ErrorMessage = "";
                return temp;
            }
        }
        #endregion

        #region Constructor 
        /// <summary>
        /// Permite la implementación del patrón Singleton
        /// </summary>
        private StoreRoomManager() 
        {
            _IsError = false;
            _ErrorMessage = "";
            _stores = WebServices.WebServices.getInstance().getStoreRooms();
            if (_stores == null)
            {
                _IsError = true;
                _ErrorMessage = Constants.ERROR_STORE_ROOM_READING;
            }
            else 
            {
                _IsError = false;
            }
        }
        /// <summary>Instancia Unica</summary>
        public static StoreRoomManager GetInstance() 
        {
            if (_instance == null)
                _instance = new StoreRoomManager();
            return _instance;
        }
        #endregion

        #region Métodos

        /// <summary>
        /// Método que se encarga de obtener la lista de todas las bodegas
        /// </summary>
        /// <returns>
        /// Obtiene una lista con todas las bodegas
        /// </returns>
        public List<StoreRoom> GetStoreRooms() 
        {
            if (_stores == null)
            {
                _IsError = true;
                _ErrorMessage = Constants.ERROR_STORE_ROOM_READING;
            }
            return _stores;
        }


        #endregion

    }
}